<template>
	<view>
		<view class="serach">
			<van-search  background="#ff0000" placeholder="请输入搜索关键词" />
		</view>
		<van-tabs bind:change="onChange">
		  <van-tab title="综合">
			  <van-card
			   v-for="(item,index) in list" :num="item.goods_number" :price="item.goods_price"
			   	:title="item.goods_name" :thumb="item.goods_big_logo" @tap="doDetail(item.goods_id)"
			  />
		  </van-tab>
		  <van-tab title="销量"><van-empty image="error" description="暂无" /></van-tab>
		  <van-tab title="价格"></van-tab>
		</van-tabs>
		
	</view>
</template>

<script>
import {ShopList} from '../../api/api.js'
	
	export default {
		data() {
			return {
				cid:'',
				query:'',
				pagenum: 1,
				pagesize: 10,
				list:[],
				arr:[],
			};
		},
		onLoad(event) {
			console.log('123',event)
			this.cid=event.id||""
			this.query=event.query||""
			this.shop()
		},
		methods:{
			async shop(){
				let res=await ShopList(
				{data:{
						query: this.query,
						cid: this.cid,
						pagenum: this.pagenum,
						pagesize: this.pagesize
					}}
				)
				
				let goods=res.goods
				this.list=goods
				console.log('sd',this.list)
			},
			doDetail(id){
				wx.navigateTo({
					url:'../detail/detail?id='+id
				})
			}
		},
		onPullDownRefresh() {
			this.pagenum=1
			this.shop()
			wx.stopPullDownRefresh()
		},
		onReachBottom() {
			this.pagenum++
			let flag=true
			if(flag){
				flag=flag
				setTimeout(()=>{
					this.shop()
					flag=true
				},1000)
			}
		}
		
	}
</script>

<style lang="scss">

</style>
